<template>
  <div class="project-Container">
    <div class="head">
      <div></div>
      <div class="opt">
        <!-- <el-button type="primary" @click.native="Add()">新增项目</el-button>
        <el-button type="primary" @click="dialogFabu = true">发布项目</el-button>-->
          <div class="search">
          <el-input
            placeholder="请输入用户名"
            suffix-icon="el-icon-search"
            v-model="userName"
            @keyup.enter.native="getList()"
          ></el-input>
      </div>
      </div>
    </div>
    <el-table :data="List" border style="width: 100%">
      <el-table-column prop="index" label="序号" width="120"></el-table-column>
      <!-- <el-table-column prop="id" label="日志id"></el-table-column> -->
      <el-table-column prop="userName" label="用户名"></el-table-column>
      <el-table-column prop="ip" label="ip地址"></el-table-column>
      <!-- <el-table-column prop="userId" label="账户id"></el-table-column> -->
      <el-table-column prop="operation" label="操作"></el-table-column>
    </el-table>

    <div class="paginat">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage4"
        :page-size="10"
        layout="total, prev, pager, next"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      search: "",
      List: [],
      total: 0,
      val: 1, //当前多少页
      currentPage4: 1,
      searchId: "",
      searchIp: "",
      userName: "",
      userId: ""
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //获取数据
    getList() {
      let url = "/sysLog/findLog";
      let params = {
        pageNum: this.val,
        pageSize: 12,
        userName: this.userName,
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.List = res.data.list;
          this.total = res.data.total;
          this.List.forEach((element, i) => {
            this.List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },
    //分页
    //分页
    handleCurrentChange(val) {
      this.val = val;
      this.getList();
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style lang="scss" scoped>
.head {
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .search {
    width: 300px;
  }
}
</style>
